package info.liuxing.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.FactoryBean;

/**
 * ColorFactoryBean
 *
 * @author liuxing
 * @summary ColorFactoryBean
 * @Copyright (c) 2018, Lianjia Group All Rights Reserved.
 * @since 2018-04-09 23:16
 */
@Slf4j
public class ColorFactoryBean implements FactoryBean<Color> {

    /**
     * 返回一个Color对象，这个对象会添加到容器中
     *
     * @return
     * @throws Exception
     */
    @Override
    public Color getObject() throws Exception {
        log.info("ColorFactoryBean...getObject");
        return new Color();
    }

    /**
     * 类型
     *
     * @return
     */
    @Override
    public Class<?> getObjectType() {
        return Color.class;
    }

    /**
     * 是否是单例
     * true：单实例，这个bean会在容器中cache一份
     * false：多实例，每次都会调用getObject获取新实例
     *
     * @return
     */
    @Override
    public boolean isSingleton() {
        return false;
    }
}
